﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace tPlat
{
    public partial class Manager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && Convert.ToBoolean(Session["Secured"]))
            {
                switch (Convert.ToBoolean(Session["SuperUser"]))
                {
                    case true:
                        {
                            
                            break;
                        }
                    case false:
                        {
                            tvMenu.Nodes.RemoveAt(1);
                            break;
                        }
                    default:
                        break;
                }
            }
            else if (!Convert.ToBoolean(Session["Secured"]))
            {
                Response.Redirect("index.aspx");
            }
        }

        protected void btLogout_Click(object sender, EventArgs e)
        {
            HotelSystem system = (HotelSystem) Application["System"];
            User user = (User)Session["User"];
            system.logoutUser(user);
            userPanel.Visible = false;
            btLogout.Visible = false;
            Session["Secured"] = false;
            Session["SuperUser"] = false;
            Response.Redirect("index.aspx");
        }

        protected void tvMenu_SelectedNodeChanged(object sender, EventArgs e)
        {
            TreeNode selected = tvMenu.SelectedNode;
            string[] parameters = selected.Value.Split('.');
            switch (parameters[0])
            {
                case "rooms":
                    {
                        switch (parameters[1])
                        {
                            case "SelectAll":
                                {
                                    RoomsSelectAll();
                                    break;
                                }

                            case "SelectFree":
                                {
                                    RoomsSelectFree();
                                    break;
                                }

                            case "Book":
                                {
                                    RoomsBook();
                                    break;
                                }

                            case "Cancel":
                                {
                                    RoomsCancel();
                                    break;
                                }

                            case "Manage":
                                {
                                    RoomsManage();
                                    break;
                                }
                            default:
                                break;
                        }
                        break;
                    }
                case "users":
                    {
                        switch (parameters[1])
                        {
                            case "SelectAll":
                                {
                                    break;
                                }

                            case "Manage":
                                {
                                    break;
                                }
                            default:
                                break;
                        }
                        break;
                    }
                default:
                    break;
            }      
        }

        public void RoomsSelectAll() { }

        public void RoomsSelectFree() { }

        public void RoomsBook() { }

        public void RoomsCancel() { }

        public void RoomsManage() { }
    }
}
